package com.redis.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;

/**
 * 作者: LCG
 * 日期: 2019/9/10 18:06
 * 描述:
 */
@Configuration
public class TestConfigure {

    @Bean
    public RedisMessageListenerContainer getRedisMessageListenerContainer(RedisConnectionFactory redisConnectionFactory,TestMessageListener testMessageListener){

        RedisMessageListenerContainer redisMessageListenerContainer=new RedisMessageListenerContainer();

        redisMessageListenerContainer.addMessageListener(testMessageListener,new PatternTopic("TEST"));

        redisMessageListenerContainer.setConnectionFactory(redisConnectionFactory);

        return redisMessageListenerContainer;

    }

}
